//logs.js
var util  = require('../../utils/util.js')
var user  = require('../../utils/user.js')
Page({
  data: {
    logs: []
  },
  onLoad: function () {
    this.setData({
      logs: (wx.getStorageSync('logs') || []).map(function (log) {
        return util.formatTime(new Date(log))
      })
    })
  },
  onReady:function(){
    // 页面渲染完成 
  },
  onShow:function(){
    // 页面显示
    if (user.checkLogin()) {
      this.setData({login:true})
    }else{
      this.setData({login:false})
      wx.redirectTo({
        url: '/pages/login/login',
        success: function(res){
          // success
        },
        fail: function(res) {
          // fail
        },
        complete: function(res) {
          // complete
        }
      })
    }
    var that = this
    user.getLoginUserInfo(function(res){
      that.setData({
        user_notices:res.data.user_notices,
        user_orders:res.data.user_orders
      })
      console.log(res.data)
    })
  }
})
